﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionnaireCopy.aspx.cs" Inherits="ZX.TR.Web.QuestionnaireCopy" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>问卷复制</title>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery.form.js" type="text/javascript"></script>
    <link href="../Styles/extendTable.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
    // <![CDATA[

            $(document).ready(function () {
                var questionnaireID = getPar1("id");
                $("#QuestionnaireID").val(questionnaireID);
                GetQuestionnaire(questionnaireID)
                parent.document.getElementById("dialog1_h").innerHTML = "问卷复制";
            });

            function GetQuestionnaire(questionnaireID) {
                var url = "../Extend/AjaxData/jsonlist.aspx?entity=V_TrQuestionnaire&condition=TrQuestionnaireID='" + questionnaireID + "'";
                $.get(url, function (d, s) {
                    var list = eval("(" + d + ")");
                    var TrQuestionnaireID = list.rows[0].TrQuestionnaireID;
                    if (typeof (TrQuestionnaireID) != "undefined") {
                        $("#QuestionnaireName").val(list.rows[0].QuestionnaireName+"_副本");
                    }
                });
            }

    // ]]> 
     </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="tableContent" id="dutyTypeTable">
            <tr>
                <td style="height:30px; width:60px;">&nbsp;问卷名称</td>
                <td>
                    <input type="hidden" id="QuestionnaireID" name="QuestionnaireID"  />
                    <input type="text" id="QuestionnaireName" name="QuestionnaireName" maxlength="50"/>
                    <span style="color: Red">*</span>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
<script type="text/javascript">
    var Entity = "ExaminationItemType";
    var Url = "";
    var instance = [{ "QuestionnaireName": "", "QuestionnaireID": ""}];
    function Save() {
        var vName = document.getElementById("QuestionnaireName").value;
        if (vName == "" || vName == null) {
            alert("问卷名称不能为空!");
            document.getElementById("QuestionnaireName").focus();
            return;
        } 
        else {
            Url = "trAjax.aspx?flag=QuestionnaireCopy" + "&QuestionnaireID=" + $("#QuestionnaireID").val() + "&QuestionnaireName=" +encodeURI($("#QuestionnaireName").val());
            SaveData();
        }
    }

    function SaveData() {
        YAHOO.util.Connect.asyncRequest('POST', Url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = res.responseText;
                    if (inventory == 1) {
                        alert("复制成功!");
                        //RefreshTreeData();
                        parent.closeWin();
                    } else {
                        alert(inventory);
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }


</script>

</html>
